<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
</head>
<body layadmin-themealias="default">

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body" pad15="">
                    <div class="layui-form" wid100="" lay-filter="">
                        <input type="hidden" name="id" value="{$model->id}">
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户昵称</label>
                            <div class="layui-input-block">
                                <div  class="layui-input" style="line-height: 38px">{$model->nick_name}</div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">达人榜名称</label>
                            <div class="layui-input-block">
                                <select name="type" lay-verify="required" lay-filter="type">
                                    <?php foreach($list as $item) {?>
                                    <option value="{$item.id}"  <?php if ($model->type == $item['id']){echo 'selected';} ?>>{$item.title}</option>
                                    <?php }?>
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">日榜</label>
                            <div class="layui-input-block">
                                <input type="text" name="day" value="{$model->day}" class="layui-input" onkeyup="clearNoNum(this)"  autocomplete="off"/>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">周榜</label>
                            <div class="layui-input-block">
                                <input type="text" name="week" value="{$model->week}" class="layui-input" onkeyup="clearNoNum(this)"   autocomplete="off"/>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">月榜</label>
                            <div class="layui-input-block">
                                <input type="text" name="month" value="{$model->month}" class="layui-input" onkeyup="clearNoNum(this)"  autocomplete="off"/>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block text-center">
                                <button class="layui-btn" lay-submit="" lay-filter="ads-add">确认保存</button>
                                <button class="layui-btn layui-btn-primary" id="close">取消</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script>
    var type = <?php echo $model->type; ?>;
    layui.config({
        base: "/layuiadmin/" //静态资源所在路径
    }).extend({
        index: "lib/index", //主入口模块
    }).use(['index', 'form', 'admin'], function () {
        var $ = layui.$, form = layui.form, admin = layui.admin;

        var index = parent.layer.getFrameIndex(window.name);

        $('#close').on("click", function () {
            parent.layer.close(index);
        });

        form.on('select(type)', function (data) {
            var value = data.value;
            if (type != value) {
                window.location = '/admin/talent/edit?id={$model->id}&type=' + value
            }
        });

        form.on('submit(ads-add)', function (obj) {
            //提交
            admin.req({
                url: '/admin/talent/edit'
                , data: obj.field
                , success: function (res) {
                    if (res.code == 0) {
                        parent.layer.close(index);
                        parent.layer.msg(res.msg, {icon: 1});
                        parent.window.location.reload();
                    }
                }
            });
            return false;
        });
    });

    function clearNoNum(obj) {
        obj.value = obj.value.replace(/[^\d]/g, "");
        obj.value = obj.value.replace(/^\./g, "");
    }
</script>
</body>
</html>
